package com.dong.springboot.rabbitmq;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import java.io.IOException;

/**
 * @author: dong peng
 * @date: 2019/2/20 10:34
 * @description:
 *
 * 简单队列模式
 */

public class SendSimple {

    public static void main(String[] args) throws IOException {
        Connection connection = ConnectionUtil.getConnection();

        // 创建通道
        Channel channel = connection.createChannel();

        // 声明队列
        String queueName = "queue1";
        channel.queueDeclare(queueName,false,false,false,null);

        // 消息内容
        String str = "Hello World";
        channel.basicPublish("", queueName, null, str.getBytes());
        System.out.println("已发送内容: " + str);

        // 关闭通道和连接
        channel.close();
        connection.close();
    }
}
